package com.xdk.templatescala.common.response;


import static com.xdk.templatescala.common.response.ResultCode.FAIL;
import static com.xdk.templatescala.common.response.ResultCode.SUCCESS;

/**
 * ResultBuild
 *
 * @author jhz
 * @date 2021/6/15
 **/
public class ResultBuild {

    public static <T> Result<T> emptySuccess(){
        return new Result<T>().setCode(SUCCESS.code).setMsg(SUCCESS.msg);
    }
    public static <T> Result<T> success(T t){
        return new Result<T>().setData(t).setCode(SUCCESS.code).setMsg(SUCCESS.msg);
    }
    public static <T> Result<T> success(T t, long totalSize){
        return new Result<T>().setData(t).setTotalSize(totalSize).setCode(SUCCESS.code).setMsg(SUCCESS.msg);
    }
    public static <T> Result<T> fail(){
        return new Result<T>().setCode(FAIL.code).setMsg(FAIL.msg);
    }

    public static <T> Result<T> fail(ResultCode code){
        return new Result<T>().setCode(code.code).setMsg(code.msg);
    }

    public static <T> Result<T> fail(ResultCode code,String msg){
        return new Result<T>().setCode(code.code).setMsg(msg);
    }

}
